<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<input type="text" value="">
<button id="button">插入数据</button>

<body>
    <!-- 2. 有一个从小到大排好序的数组。现输入一个数，要求按原来的规律将它插入数组中。 -->
    <script src="./js/sort方法源码.js"></script>
    <script>
        var arr = [1, 9, 17, 24, 30, 41, 50, 70, 80, 100]
        // var arr1 = [];
        var inp = document.getElementsByTagName('input');
        var btn = document.getElementById('button');
        console.log(arr);
        btn.onclick = function () {
            var num = inp[0].value
            arr.push(parseInt(num));
            arr.sort(function (a, b) {
                return a - b;
            });
            console.log(arr);
        }
    </script>












    <!-- /* arr1.push(res) */
/* for(var i=0;i<arr.length;i++){
    if(inp.value>arr[i]){     
    }
} */ -->
</body>

</html>